package com.anxin.act.task.entity;

import com.anxin.act.task.vo.TaskVo;
import com.anxin.act.utils.ActProcessUtils;
import com.anxin.act.utils.ActTaskUtils;
import com.anxin.common.utils.DateUtils;
//import io.swagger.annotations.ApiModel;
//import io.swagger.annotations.ApiModelProperty;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskInfo;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.anxin.framework.aspectj.lang.annotation.Excel;
import com.anxin.framework.web.entity.BaseEntity;
import java.util.Date;

/**
 * 加签任务历史记录对象 wf_act_hi_task
 *
 * @author jbs
 * @date 2021-10-22
 */
//@ApiModel(description = "加签任务历史记录")
public class WfActHiTask extends BaseEntity<WfActHiTask>{
    private static final long serialVersionUID = 1L;

    /** 流程实例ID */
    //@ApiModelProperty(value = "流程实例ID",position=20)
    private String actId;

    /** 原始的activiti任务的ID */
    //@ApiModelProperty(value = "原始的activiti任务的ID",position=30)
    private String actTaskId;

    /** 原始的activiti任务的taskKey */
    //@ApiModelProperty(value = "原始的activiti任务的taskKey",position=40)
    private String actTaskKey;

    /** 待办标题 */
    //@ApiModelProperty(value = "待办标题",position=50)
    private String actName;

    /** 加签类型 */
    //@ApiModelProperty(value = "加签类型",position=50)
    private String type;

    /** 来源类型 */
    //@ApiModelProperty(value = "来源类型",position=60)
    private String sourceType;

    /** 来源任务ID */
    //@ApiModelProperty(value = "来源任务ID",position=70)
    private String sourceId;

    /** 开始时间 */
    //@ApiModelProperty(value = "开始时间",position=80)
    private Date startTime;

    /** 审批时间 */
    //@ApiModelProperty(value = "审批时间",position=90)
    private Date approvalTime;

    /** 审批人 */
    //@ApiModelProperty(value = "审批人",position=100)
    private String assignee;


    /** 是否可以输入审批结果 */
    //@ApiModelProperty(value = "是否可以输入审批结果",position=130)
    private String approvalResults;

    /** 是否可以撤回 */
    //@ApiModelProperty(value = "是否可以撤回",position=140)
    private String withdraw;

    /**
     * 是否挂起 Y:挂起  N：正常
     */
    //@ApiModelProperty(value = "是否挂起 Y:挂起  N：正常",position=120)
    private String hang;

    public WfActHiTask(){

    }

    /**
     * 初始化
     * @param id 任务ID
     */
    public WfActHiTask(String id){
        this.id = id;
        //是否可以撤回 Y 可以 N 不可以
        this.withdraw = "Y";
        this.approvalTime = DateUtils.getNowDate();
    }

    /**
     * 初始化
     * @param wfActRuTask
     */
    public WfActHiTask(WfActRuTask wfActRuTask, String sourceType,String type){
        this.sourceType = sourceType;
        this.actId = wfActRuTask.getActId();
        this.actTaskId = wfActRuTask.getActTaskId();
        this.actTaskKey = wfActRuTask.getActTaskKey();
        this.sourceId = wfActRuTask.getId();
        this.actName = wfActRuTask.getActName();
        this.startTime = wfActRuTask.getStartTime();
        this.approvalTime = new Date(System.currentTimeMillis());
        this.assignee = wfActRuTask.getAssignee();
        this.approvalResults = wfActRuTask.getApprovalResults();
        this.hang = "N";
        this.type = type;


    }


    /**
     * 初始化
     * @param taskId 任务ID
     * @param sourceType 来源类型
     */
    public WfActHiTask(String taskId, String sourceType,String type){
        this.sourceType = sourceType;

        Task task = ActTaskUtils.getTask(taskId);
        // 获取对应流程实例信息
        //ProcessInstance processInstance = ActProcessUtils.getProcessInstance(task.getProcessInstanceId());
        this.actId = task.getProcessInstanceId();
        this.actTaskId = task.getId();
        this.actTaskKey = task.getTaskDefinitionKey();
        this.sourceId = task.getId();
        this.actName = task.getName();
        this.startTime = task.getCreateTime();
        this.approvalTime = new Date(System.currentTimeMillis());
        this.assignee = task.getAssignee();
        this.hang = "N";
        this.type = type;

    }


    public void setActId(String actId){
        this.actId = actId;
    }

    public String getActId(){
        return actId;
    }
    public void setActTaskId(String actTaskId){
        this.actTaskId = actTaskId;
    }

    public String getActTaskId(){
        return actTaskId;
    }
    public void setActTaskKey(String actTaskKey){
        this.actTaskKey = actTaskKey;
    }

    public String getActTaskKey(){
        return actTaskKey;
    }
    public void setActName(String actName){
        this.actName = actName;
    }

    public String getActName(){
        return actName;
    }
    public void setSourceType(String sourceType){
        this.sourceType = sourceType;
    }

    public String getSourceType(){
        return sourceType;
    }
    public void setSourceId(String sourceId){
        this.sourceId = sourceId;
    }

    public String getSourceId(){
        return sourceId;
    }
    public void setStartTime(Date startTime){
        this.startTime = startTime;
    }

    public Date getStartTime(){
        return startTime;
    }

    public Date getApprovalTime() {
        return approvalTime;
    }

    public void setApprovalTime(Date approvalTime) {
        this.approvalTime = approvalTime;
    }

    public void setAssignee(String assignee){
        this.assignee = assignee;
    }

    public String getAssignee(){
        return assignee;
    }

    public void setApprovalResults(String approvalResults){
        this.approvalResults = approvalResults;
    }

    public String getApprovalResults(){
        return approvalResults;
    }
    public void setWithdraw(String withdraw){
        this.withdraw = withdraw;
    }

    public String getWithdraw(){
        return withdraw;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getHang() {
        return hang;
    }

    public void setHang(String hang) {
        this.hang = hang;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("actId", getActId())
            .append("actTaskId", getActTaskId())
            .append("actTaskKey", getActTaskKey())
            .append("actName", getActName())
            .append("sourceType", getSourceType())
            .append("sourceId", getSourceId())
            .append("startTime", getStartTime())
            .append("endTime", getEndTime())
            .append("assignee", getAssignee())
            .append("approvalResults", getApprovalResults())
            .append("withdraw", getWithdraw())
            .toString();
    }
}
